// JavaScript Document
/*
	每個網頁共同都會用到的Script
	使用的網頁
		1.	main.php
		2.	php...
		
*/
var speed = 10;		//每次移動的距離
	i=-speed;			//移動距離的和
	startPos = 0;		//第一張的位置
	endPos = -(speed*2*8);	//最後一張的位置
	//往左移
	function lt(){
		//宣告temp變數來存div_img的posLeft值
		var temp = document.getElementById("div_img").style.posLeft;
		if(temp==endPos) stop();
		if(temp>endPos){
			document.getElementById("div_img").style.left=i;
			i-=speed;
		}
	}
	//往右移
	function rt(){
		//宣告temp變數來存div_img的posLeft值
		var temp = document.getElementById("div_img").style.posLeft;
		if(temp==startPos) stop();
		if(temp<startPos){
			document.getElementById("div_img").style.left=i+(speed*2);
			i+=speed;
		}
	}
	//停止移動
	function stop(){
		clearInterval(timer);
	}

	function setTimer(direction){
		if ( direction.length >0 ){
			if ( direction.toLowerCase() == "left" ){
				timer=setInterval("lt()",'50');
			} else {
				timer=setInterval("rt()",'50');
			}
					
		}
	}