var molock = 0;	//判斷鎖定 0解鎖 1鎖定
var videonum = 0;
function motion(c,step,pnum){

	if(molock==0){
		molock = 1;
	}else{
		return false;	
	}

	var box = document.getElementById("mybox");
	var max = box.getElementsByTagName("div")[0].offsetWidth;
	var now = box.scrollLeft;
	var unit = step;
	var end;

	if(box.scrollLeft==0 && c.id=='prev'){
		molock = 0;
		return false;
	}
	
	if(box.scrollLeft==step*(pnum-1) && c.id=='next'){
		molock = 0;
		return false;
	}

	pause('mflash'+videonum);	//停止

	if(c.id == 'prev'){
		videonum = videonum-1;	
	}else{
		videonum = videonum+1;			
	}

	if(typeof(c)=='number'){
		end = (c-1)*unit;
	}else{
		var id = c.id;
		end = {"begin":0,"prev":now-unit,"next":now+unit,"end":max}[id];
	}
	
	var dir = "scrollLeft";

	if(typeof(et)!='undefined'){
		clearInterval(et);
	}

	et=setInterval(function(){
		var diff=(end-box[dir])*0.1;
		box[dir] +=Math[diff>0?'ceil':'floor'](diff);
		if(diff==0){
			clearInterval(et);
			document.getElementById("vt1").innerHTML = videotit[videonum];
			document.getElementById("vt2").innerHTML = videocon[videonum];
			molock = 0;
		}
	},10);
}



/**
* 獲取影片剪輯
*/
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}


//停止
function pause(id){
	try{
		thisMovie(id).play_pause();
	}catch(err){

	}

}
