function setDisplay() { var imgElement = document.getElementById("imgs"); imgElement.moving = setTimeout("setMove('show')",3000); } function moveImg(to) { if (from == to ){return}; var imgElement = document.getElementById("imgs"); var textElement = document.getElementById("texts"); from = parseInt(imgElement.style.left) if (from > to) {var inc = Math.max(Math.ceil((from - to)/10),1);from = from - inc}; if (from < to) {var inc = Math.max(Math.ceil((to - from)/10),1);from = from + inc}; imgElement.style.position = "absolute"; imgElement.style.left = from + "px"; imgElement.moving = setTimeout("moveImg(to)",wait); } function setMove(type) { var imgElement = document.getElementById("imgs"); if (imgElement.moving) { clearTimeout(imgElement.moving); } if (imgElement.showing) { clearTimeout(imgElement.showing); } if (!imgElement.style.left) {imgElement.style.left="0px";} from = parseInt(imgElement.style.left); var terminus = -(imgWidth*(imgNo-1)); switch (type) { case "right": to = Math.max(imgWidth*(Math.floor(from/imgWidth) -1),(imgNo-1)*-imgWidth);break; case "left": to = Math.min(imgWidth*(Math.ceil(from/imgWidth) + 1),0);break; case "end": to = terminus; break; case "start": to = 0; break; case "show": to = Math.max(imgWidth*(Math.floor(from/imgWidth) -1),(imgNo-1)*-imgWidth); showOn = true; break; default: alert("error in move type : "+type); } moveImg(to); if (showOn) { if (from != terminus) { imgElement.showing = setTimeout("setMove('right')",6000); } else { showOn = false; } } } function stopShow() {showOn = false} var imgWidth=120, imgNo = 16, wait = 50, from=0, to=0, showOn = false; window.onload=setDisplay;