
verticalScrollObjects = {};
function verticalScrollObject(divId, iniX, iniY) {
	this.id = divId;
	verticalScrollObjects[this.id] = this;
	this.animString = "verticalScrollObjects." + this.id;
	this.verLoad(divId, iniX, iniY);
}
verticalScrollObject.prototype.verLoad = function (divId, iniX, iniY) {
	if (!document.getElementById) {
		return;
	}
	var scrollingDiv;
	this.scrollingDiv = document.getElementById(divId);
	this.scrollingDiv.style.top = this.y = iniY;
	this.scrollingDiv.style.left = this.x = iniX;
	this.ready = true;
};
verticalScrollObject.verSlideDur = 500; // duration of glide
verticalScrollObject.verScrollBy = function (divId, x, y, dur, hideWhenStop) {
	if (verticalScrollObjects[divId]) {
		verticalScrollObjects[divId].verGlideBy(x, y, dur, hideWhenStop);
	}
};
verticalScrollObject.prototype.verGlideBy = function (dx, dy, dur, hideWhenStop) {
	if (!document.getElementById || this.isMoving) {
		return;
	}
	this.verSlideDur = dur || verticalScrollObject.verSlideDur;
	this.destX = this.destY = this.distX = this.distY = 0;
	this.startX = this.x;
	this.startY = this.y;
	this.distY = dy;
	this.distX = dx;
	this.destX = this.startX + this.distX;
	this.destY = this.startY + this.distY;
	this.hideWhenStop = hideWhenStop;
	this.isMoving = true;
	this.per = Math.PI / (2 * this.verSlideDur);
	this.slideStart = (new Date()).getTime();
	this.aniTimer = setInterval(this.animString + ".verDoSlide()", 10);
};
verticalScrollObject.prototype.verDoSlide = function () {
	var elapsed = (new Date()).getTime() - this.slideStart;
	if (elapsed < this.verSlideDur) {
		var x = this.startX + this.distX * Math.sin(this.per * elapsed);
		var y = this.startY + this.distY * Math.sin(this.per * elapsed);
		this.verShiftTo(this.scrollingDiv, x, y);
	} else {
		clearInterval(this.aniTimer);
		this.isMoving = false;
		this.verShiftTo(this.scrollingDiv, this.destX, this.destY);
		if (this.hideWhenStop) {
			this.scrollingDiv.style.visibility = "hidden";
		}
	}
};
verticalScrollObject.prototype.verShiftTo = function (scrollingDiv, x, y) {
	if (!scrollingDiv.style) {
		return;
	}
	scrollingDiv.style.left = (this.x = x) + "px";
	scrollingDiv.style.top = (this.y = y) + "px";
};
function initVerticalScroll(itemHeight) {
	if (document.getElementById) {
		slideShowList = document.getElementById("nav");
		verSlideShowItems = 0;
		slideShowChildNodes = slideShowList.childNodes;
		for (i = 0; i < slideShowChildNodes.length; i++) {
			if (slideShowChildNodes[i].nodeName == "LI") {
				verSlideShowItems++;
			}
		}
		slideTopButVar = document.getElementById("topArrow");
		slideBottomButVar = document.getElementById("bottomArrow");
		if (verSlideShowItems > 5) {
			slideBottomButVar.style.display = "block";
		} else {
			slideBottomButVar.style.display = "none";
		}
		var slideShow = new verticalScrollObject("verticalslideshow", 0, 0);
		liHeight = itemHeight;
	}
}
function initVerticalScrollSearch(itemHeight) {
	if (document.getElementById) {
		slideShowList = document.getElementById("nav");
		verSlideShowItems = 0;
		slideShowChildNodes = slideShowList.childNodes;
		for (i = 0; i < slideShowChildNodes.length; i++) {
			if (slideShowChildNodes[i].nodeName == "LI") {
				verSlideShowItems++;
			}
		}
		slideTopButVar = document.getElementById("topArrow");
		slideBottomButVar = document.getElementById("bottomArrow");
		if (verSlideShowItems > 8) {
			slideBottomButVar.style.display = "block";
		} else {
			slideBottomButVar.style.display = "none";
		}
		var slideShow = new verticalScrollObject("verticalslideshow", 0, 0);
		liHeight = itemHeight;
	}
}
verCurrentItem = 1;
function verSlider(direction) {
	if (!verticalScrollObjects["verticalslideshow"].isMoving) {
	//Begin  (Anu-September 16),mantis issue 1961-"Directory" scrolling should be per-page
		/* 
		tempItem = verCurrentItem + direction;
		if (tempItem > 0 && tempItem <= verSlideShowItems - 7) {
			if (tempItem == 1) {
				slideTopButVar.style.display = "none";
			} else {
				slideTopButVar.style.display = "block";
			}
			if (tempItem == verSlideShowItems - 7) {
				slideBottomButVar.style.display = "none";
			} else {
				slideBottomButVar.style.display = "block";
			}
			verticalScrollObject.verScrollBy("verticalslideshow", 0, -1 * direction * liHeight);
			verCurrentItem += direction;
		}*/
		    var cnt=verSlideShowItems - 8;
                cnt=cnt * liHeight;
		
		verticalScrollObject.verScrollBy("verticalslideshow", 0, -1 * direction * cnt);
		if (direction == -1) {
			slideBottomButVar.style.display = "block";
			slideTopButVar.style.display = "none";
		} else {
			slideTopButVar.style.display = "block";
			slideBottomButVar.style.display = "none";
		}
       //end (Anu-September 16),mantis issue 1961-"Directory" scrolling should be per-page
	}
}
verCurrentItemHome = 1;
function verSliderHome(direction) {

	if (!verticalScrollObjects["verticalslideshow"].isMoving) {
        //Begin  (Anu-September 16),mantis issue 1961-"Directory" scrolling should be per-page
		/*  tempItem = verCurrentItemHome + direction ;
                
               
                if (tempItem > 0 && tempItem <= verSlideShowItems - 6) {
                        if (tempItem == 1){
                                slideTopButVar.style.display = "none" ;
                        } else {
                                slideTopButVar.style.display = "block" ;
                        }
                        if (tempItem == verSlideShowItems - 6){
                                slideBottomButVar.style.display = "none" ;
                        } else {
                                slideBottomButVar.style.display = "block" ;
                        }
                        verticalScrollObject.verScrollBy('verticalslideshow',0,-1*direction*liHeight);
                        verCurrentItemHome += direction;
                }*/
                var cnt=verSlideShowItems - 7;
                cnt=cnt * liHeight;
               
               	verticalScrollObject.verScrollBy("verticalslideshow", 0, -1 * direction * cnt);
		if (direction == -1) {
			slideBottomButVar.style.display = "block";
			slideTopButVar.style.display = "none";
		} else {
			slideTopButVar.style.display = "block";
			slideBottomButVar.style.display = "none";
		}
       //end (Anu-September 16),mantis issue 1961-"Directory" scrolling should be per-page
	}
}

