// ·£´ý³ëÃâ Div°ü·Ã ÇÔ¼ö
function randomShowDiv(divID) {
	this.divID = divID;
	this.divOrderArray = new Array();
	this.showDivNum = 0;
	this.isRandom = false;
	this.tid = null;
	this.interval = 5000;
}

randomShowDiv.prototype.init = function () {
	var self = this;
	var motherDiv = document.getElementById(self.divID);
	var cont = motherDiv.childNodes;

	for (var i=0; i<cont.length; i++) {
		if(cont[i].className == 'randomShowDiv') {
			cont[i].style.display = "none";
			self.divOrderArray.push(cont[i].id);
		}
	}

	if(self.isRandom) self.showDivNum = parseInt(Math.random()*100)%self.divOrderArray.length;
	self.showDiv(self.showDivNum);
}

randomShowDiv.prototype.stopRolling = function () {
	var self = this;
	if(self.tid != null) clearInterval(self.tid);
}

randomShowDiv.prototype.startRolling = function (objID) {
	var self = this;
	if(self.tid != null) clearInterval(self.tid);
	functionStr = objID+".showNextDiv();";
	self.tid = setInterval(functionStr,self.interval); // ÀÚµ¿·Ñ¸µ..
}

randomShowDiv.prototype.showDiv = function (n) {
	var self = this;
	for(i=0;i<self.divOrderArray.length;i++){
		
		tmpObj = document.getElementById(self.divOrderArray[i]);
		if(i==n) tmpObj.style.display = "block";
		else tmpObj.style.display = "none";		
	}
}

randomShowDiv.prototype.showNextDiv = function () {
	var self = this;
	self.showDivNum++;
	if(self.showDivNum >= self.divOrderArray.length) self.showDivNum = 0;
	self.showDiv(self.showDivNum);
}

randomShowDiv.prototype.showPrevDiv = function () {
	var self = this;
	self.showDivNum--;
	if(self.showDivNum < 0) self.showDivNum = self.divOrderArray.length-1;
	self.showDiv(self.showDivNum);
}