﻿// JScript File

var PhotoAlbum=new Array(), PhotoPreload=new Array(), MousePos, SlideEnd
var PhotoSpac = 8		//縮圖間距
var SlideMode = 1		//初始捲動方向與速度 ( 1:向左 -1:向右 0:靜止 )
var PhotoPath = "./Images/"		//圖片路徑 ( 若與網頁位置相同請設為 ./ 或空白 )

//以下為相片資料
PhotoAlbum[0]=new Array(
	"研磨加工",	//相片標題
	"home01.jpg")	//相片縮圖
	
PhotoAlbum[1]=new Array(
	"金属加工",
	"home02.jpg")
	
PhotoAlbum[2]=new Array(
	"芯取",
	"home03.jpg")

PhotoAlbum[3]=new Array(
	"洗浄",
	"home04.jpg")
	
PhotoAlbum[4]=new Array(
	"製造",
	"home05.jpg")

PhotoAlbum[5]=new Array(
	"組立",
	"home06.jpg")
	
PhotoAlbum[6]=new Array(
	"検査",
	"home07.jpg")

//預先載入相片 ( 縮圖 )
for(i=0;i<PhotoAlbum.length;i++){
PhotoPreload[i]=new Image()
PhotoPreload[i].src=PhotoPath+PhotoAlbum[i][2]
}

function PhotoCheck(){
var isLoaded=true
for(i=0;i<PhotoPreload.length;i++){
    if(PhotoPreload[i].readyState!="complete")
        isLoaded=false
    }

if(isLoaded){
BuildSlider()
}else{
LoadingDots.innerHTML=(LoadingDots.innerHTML=="....")?"":LoadingDots.innerHTML+"."
setTimeout("PhotoCheck()",300)
}
ShowInfo(0)
}

function BuildSlider(){
var PHTML="<table border=\"0\" cellspacing=\""+PhotoSpac+"\" cellpadding=\"0\"><tr>"
for(i=0;i<PhotoAlbum.length;i++){
PHTML+="<td id=\"c_"+i+"\" class=\"item_out\" hidefocus=\"true\" onmouseover=\"PhotoHilight('c_"+i+"','item_over');top.status='"+PhotoAlbum[i][0]+"';return true\" onmouseout=\"PhotoHilight('c_"+i+"','item_out');top.status=''\" onclick=\"ShowInfo("+i+")\"><img alt=\"\" src=\""+PhotoPreload[i].src+"\" border=\"0\"><br>"+PhotoAlbum[i][0]+"</td>"
}
for(i=0;i<PhotoAlbum.length;i++){
PHTML+="<td id=\"m_"+i+"\" class=\"item_out\" hidefocus=\"true\" onmouseover=\"PhotoHilight('m_"+i+"','item_over');top.status='"+PhotoAlbum[i][0]+"';return true\" onmouseout=\"PhotoHilight('m_"+i+"','item_out');top.status=''\" onclick=\"ShowInfo("+i+")\"><img alt=\"\" src=\""+PhotoPreload[i].src+"\" border=\"0\"><br>"+PhotoAlbum[i][0]+"</td>"
}
PHTML+="</tr></table>"
SlideObj.innerHTML=PHTML
//SlideEnd=-(SlideObj.offsetWidth/2)+PhotoSpac
SlideBox.style.height=SlideObj.offsetHeight
SlideBox.style.width=SlideBar.clientWidth
SlideBox.style.clip="rect(0 "+SlideBar.clientWidth+" "+SlideObj.offsetHeight+" 0)"
setInterval("ScrollObject()",1)
}

function PhotoHilight(el,s){
eval(el).className=s
}

function ScrollObject(){
SlideEnd=-(SlideObj.offsetWidth/2)+PhotoSpac
SlideObj.style.posLeft-=SlideMode
SlideObj.style.posLeft=SlideObj.style.posLeft<=SlideEnd?0:SlideObj.style.posLeft>0?SlideEnd:SlideObj.style.posLeft
}

function AdjSpeed(){
MousePos=event.clientX-SlideBar.offsetLeft
if(MousePos<parseInt(SlideBox.offsetWidth*0.04)){SlideMode=-4}
if(MousePos>parseInt(SlideBox.offsetWidth*0.04)&&MousePos<parseInt(SlideBox.offsetWidth*0.11)){SlideMode=-3}
if(MousePos>parseInt(SlideBox.offsetWidth*0.11)&&MousePos<parseInt(SlideBox.offsetWidth*0.21)){SlideMode=-2}
if(MousePos>parseInt(SlideBox.offsetWidth*0.21)&&MousePos<parseInt(SlideBox.offsetWidth*0.37)){SlideMode=-1}
if(MousePos>parseInt(SlideBox.offsetWidth*0.37)&&MousePos<parseInt(SlideBox.offsetWidth*0.63)){SlideMode=0}
if(MousePos>parseInt(SlideBox.offsetWidth*0.63)&&MousePos<parseInt(SlideBox.offsetWidth*0.79)){SlideMode=1}
if(MousePos>parseInt(SlideBox.offsetWidth*0.79)&&MousePos<parseInt(SlideBox.offsetWidth*0.89)){SlideMode=2}
if(MousePos>parseInt(SlideBox.offsetWidth*0.89)&&MousePos<parseInt(SlideBox.offsetWidth*0.96)){SlideMode=3}
if(MousePos>parseInt(SlideBox.offsetWidth*0.96)){SlideMode=4}
}

var MyTimer1 ,MyTimer2
function ShowInfo(n){
PhotoPrev.innerHTML="<img alt=\"\" src=\""+PhotoPath+PhotoAlbum[n][1]+"\" style=\"border:1px solid #000\" onload=\"setTimeout('PhotoView()',300)\">"
PhotoDesc.innerHTML="<span class=\"h2\">Title：<br />"+PhotoAlbum[n][0]+"</span><hr />"+PhotoAlbum[n][3]
clearInterval(MyTimer1)
Waiting.style.visibility="visible"
}

function PhotoView(){
clearInterval(MyTimer1)
Waiting.style.visibility="hidden"
}

document.oncontextmenu=new Function("return false")
document.onselectstart=new Function("return false")
document.ondragstart  =new Function("return false")
