function ImageScroll() {
	this.path = "";
	this.data = new Array();
	this.speed = 1250;
	this.container_width = 800;
	this.easing = "swing";
	this.container = "#image_container";
	this.index = 0;
	this.next_index = 0;
	this.timer = 0;
	this.timer_interval = 10000;
	
	this.init = function(path, data) {
		this.path = path;
		this.data = data;
		
		var output = "";
		for(var i=0; i<this.data.length; i++) {		
			output += "<img src=\"" + this.path + this.data[i][0] + "\" />";
		}
		$(this.container).html(output);
		
		this.timer = setInterval("image_scroll.move(0)", this.timer_interval);
	}
	
	this.move = function(direction) {
		if (direction == 0) {
			direction = 1;	
		} else {
			clearInterval(this.timer);	
		}
		this.next_index = this.index + direction;
		
		if (this.next_index >= this.data.length)
			this.next_index = 0;
		else if (this.next_index < 0)
			this.next_index = this.data.length - 1;
			
		this.display();
	}
	
	this.display = function() {
		var total_width = this.get_total_width(this.next_index);
		
		var x_pos = -total_width + ((this.container_width - this.data[this.next_index][1]) / 2);

		$(this.container).animate(
									  {
										"left": x_pos + "px"
									  }, this.speed, this.easing );
		this.index = this.next_index;
	}
	
	this.get_total_width = function(index) {
		var total = 0;
		for(var i=0; i<index;  i++) {
			total += this.data[i][1];
		}
		return total;
	}
}

var image_scroll = new ImageScroll();


$(document).ready(function () {
	var data = new Array(
						 Array("downtown.jpg", 800),
						 Array("industrial.jpg", 800),
						 Array("retail.jpg", 800),
						 Array("corporate.jpg", 800)
						 );
	
	image_scroll.init("images/image_scroll/", data);
});