

BlogCnOverTurnables = { //褫楹蛌腔ㄛ膘祜硐蚚芞ㄛflash婓ff笢珆尨祥淏都﹝
	items: new Array(),
	add: function (element) {
		var e = element
		e.style.overflow = "hidden" //扢CSS欴宒閉堤窒煦笐紲
		e.style.position = "relative" //扢CSS欴宒閉堤窒煦笐紲
		var options = {
		  speed: 50, //unit: ms
		  delay: 5, //unit:s
		  step: 10,
		  direction: 1 //1 砃奻ㄛ 2砃酘ㄛ(綴醱TODO:)坻 
		}.extend(arguments[1] || {})
		if (options.direction == 1) { //up
			var size = parseInt(e.style.height)
			var styleP = "top"
			var styleP2 = "left"
		} else if (options.direction == 2) {
			var size = parseInt(e.style.width)
			var styleP = "left"
			var styleP2 = "top"
		}//if	
		var childs = e.childNodes
		for (var i=0; i< childs.length; i++) {
			childs[i].style.position = "absolute"
			childs[i].style[styleP] = (i*size)+"px"
			childs[i].style[styleP2] = "0px"
		}//for
		this.items.push(e)
		var i = this.items.length-1
		this.items[i].options = options
		setTimeout("BlogCnOverTurnables.move("+i+")", options.delay*1000)		
	}//add
	,
	move: function (index) {
		var e = this.items[index]
		var step = this.items[index].options.step
		var speed = this.items[index].options.speed
		var delay = this.items[index].options.delay
		var size = (this.items[index].options.direction == 1) ? parseInt(e.style.height) : parseInt(e.style.width) //TODO: 跦擂祥肮腔direction統杅祥肮腔硉
		var childs = e.childNodes
		var len = childs.length
		var strDirection = (this.items[index].options.direction == 1) ? "top" : "left" //TODO: 跦擂祥肮腔direction統杅祥肮腔硉
		this.isEnd = function (childs, size, step, count, strDirection) {
			for (var i=0; i<count; i++) {
				if (parseInt(childs[i].style[strDirection])<=-size+step) return true
			}//for
		}//isEnd
		this.getPosition = function (currentPosition, count, size) {
			var p = currentPosition
			for (var i=0; i<count; i++) {
				if (p<i*size) {
					if ((i-1)<0) return (count-1)*size+"px"
					return ((i-1)*size)+"px"
				}
			}//for
		}//getPosistion
		if (this.isEnd(childs, size, step, len, strDirection)) { //彆善階萸	
			for (var i=0; i<len; i++) {
				childs[i].style[strDirection] = this.getPosition(parseInt(childs[i].style[strDirection]), len, size)
			}
			setTimeout("BlogCnOverTurnables.move("+index+")", delay*1000)
		} else { //羶善階萸	
			for (var i=0; i<len; i++) {
				childs[i].style[strDirection] = (parseInt(childs[i].style[strDirection]) - step) + "px"
			}
			setTimeout("BlogCnOverTurnables.move("+index+")", speed)
		}
	}//move	
} //BlogCnOverTurnables