var ImageGallery = function(id,divout,divin){
	this.id = id;
	this.innerid = divin;
	this.outerid = divout;
	this.innerContent = function(){return (typeof(this.innerid)=="string") ? document.getElementById(this.innerid) : this.innerid;}
	this.outerContent = function(){return (typeof(this.outerid)=="string") ? document.getElementById(this.outerid) : this.outerid;}
	this.maxScroll = 0;
	this.minScroll = 0;
	this.SPEED = 10;
	this.INTERVAL = 50;
	this.timerInterval = null;
	this.init();
	return this;
}

ImageGallery.prototype = {
	init : function(){
		var outcomp = this.outerContent();
		var incomp = this.innerContent();
	},
	freqLeftMove : function(){
		this.stopMoving();
		this.moveLeft();
		this.timerInterval = setTimeout(this.id + ".freqLeftMove();",this.INTERVAL);
	},
	moveLeft : function(){
		outerwidth = this.outerContent().offsetWidth;
		innerwidth = this.innerContent().offsetWidth;
		currpos = this.innerContent().offsetLeft;
		if((currpos - this.SPEED) > (-1 * (innerwidth - outerwidth))){
			currpos -= this.SPEED;
		}else{
			if((-1 * (innerwidth - outerwidth)) > 0){
				currpos = 0;
			}else{
				currpos = (-1 * (innerwidth - outerwidth));
			}			
		}
		this.innerContent().style.left = currpos + "px";
	},
	freqRightMove : function(){
		this.stopMoving();
		this.moveRight();
		this.timerInterval = setTimeout(this.id + ".freqRightMove();",this.INTERVAL);
	},
	moveRight : function(){
		outerwidth = this.outerContent().offsetWidth;
		innerwidth = this.innerContent().offsetWidth;
		currpos = this.innerContent().offsetLeft;
		if((currpos + this.SPEED) < 0){
			currpos += this.SPEED;
		}else{
			currpos = 0;
		}
		this.innerContent().style.left = currpos + "px";
	},
	stopMoving : function(){
		clearTimeout(this.timerInterval);
	}
}
