$(document).ready(function() {
	if ($("#vertical_scroll_container_div").length > 0){
		part_scroller.beginScroll('vertical_scroll_container_div');
	}
});

function scroller(name){	
	this.currentTimeoutID;
	this.mainChild;
	this.baseHeight;
	this.passedHeight = 0;
	this.maxHeight;
	this.firstTime = true;
	this.scrollerName = name;
}

scroller.prototype.beginScroll = function (div_id){
	var container = document.getElementById(div_id);
	var all_children = container.getElementsByTagName('div');
	var children = new Array();
	var j = 0;
	for (var i = 0; i < all_children.length; i++){
		if (all_children[i].className == 'inside_scroll_container'){
			children[j++] = all_children[i];
		}
	}
	var num_children = children.length;
	this.baseHeight = children[0].offsetHeight;
	this.maxHeight = (num_children - 1) * this.baseHeight;
	this.mainChild = children[0];
	this.scrollStart();
}
	
scroller.prototype.scrollStart = function (scroll_inst){
	var pos;
	if (this.passedHeight == this.maxHeight){
		this.passedHeight = -1 * this.baseHeight;
	}
	if (this.firstTime == true){
		this.passedHeight = 0;
		this.firstTime = false;
	}
	else {
		this.passedHeight = this.passedHeight + 10;
	}
	if (this.passedHeight > 0){
		pos = '-' + this.passedHeight + 'px';
	}
	else if (this.passedHeight < 0){
		pos = (-1 * this.passedHeight) + 'px';
	}
	else {
		pos = '0px';
	}
	this.mainChild.style.marginTop = pos;
	pos = this.passedHeight % this.baseHeight;
	if(true){ //confirm(this.passedHeight + ' - ' + this.baseHeight + ': ' + pos)){
		if (pos == 0){
			clearTimeout(this.currentTimeoutID);
			eval ('this.currentTimeoutID = setTimeout(function(){' + this.scrollerName + '.scrollStart()},5000);');
		} else {
			eval ('this.currentTimeoutID = setTimeout(function(){' + this.scrollerName + '.scrollStart()},25);');
		}
	}
}
