//date function
RightNow=new Date();
var themonth;
var month=RightNow.getMonth()+1;
if (month==1) themonth = "January";
if (month==2) themonth = "February";
if (month==3) themonth = "March";
if (month==4) themonth = "April";
if (month==5) themonth = "May";
if (month==6) themonth = "June";
if (month==7) themonth = "July";
if (month==8) themonth = "August";
if (month==9) themonth = "Sep";
if (month==10) themonth = "October";
if (month==11) themonth = "Nov";
if (month==12) themonth = "Dec";

var date=RightNow.getDate();
var year=RightNow.getYear();
var day=RightNow.getDay();
if (year==106){year="2006";}
if (year==107){year="2007";}
if (year==108){year="2008";}
if (year==109){year="2009";}
if (year==110){year="2010";}
if (year==111){year="2011";}
if (year==112){year="2012";}
if (year==113){year="2013";}
if (year==114){year="2014";}


//preload nav rollovers
for(q=0;q<8;q++)
{
eval("n"+q+"On = new Image()")
eval("n"+q+"On.src = '/image/Manualbar/nav"+q+"_On.gif'")
eval("n"+q+"Off = new Image()")
eval("n"+q+"Off.src = '/image/Manualbar/nav"+q+".gif'")
}



//rollover function
function roll(sec,num,state,layer)
{
if (layer=="") eval("document.images['"+ sec + num + "'].src =" + sec + num + state + ".src;");
else 
 {
  if (document.all) {
  	eval("document.images['"+ sec + num + "'].src =" + sec + num + state + ".src;");
  }	
  if (document.layers){
  	  eval("document.layers."+layer+".document.images['" + sec + num + "'].src = " + sec + num + state + ".src;");
  }	  
  if (!document.all && document.getElementById) {
  	eval("document.getElementById('" + sec + num + "').src = " + sec + num + state + ".src;");
  }	
 }
}



//set up layer call
var isIE, isNS, isNS6, isDOM, lR, sR, vis, invis, myTimeOut, goName;
	if (document.all) {isIE= true;lR="document.all.";sR=".style";vis="visible";invis="hidden";}
	if (document.layers){isNS = true;lR="document.layers.";sR="";vis="show";invis="hide";}
	if (document.getElementById &&!isIE) {isDOM=true;lR = "document.getElementById('";sR = "').style";invis ="hidden";vis = "visible"}
	if (isDOM == true && navigator.appName =="Netscape") isNS6 = true;
	
var oldwhich = 1;
var x=0;
var layerTimer;
	
//turn on layer and rollover
	function layOver(which)
	{
	x=0;
	l = eval(lR + "l" + which + sR);
	eval("roll('n',"+which+",'On','lN')")
	if (oldwhich != which)
	{
		ol = eval(lR + "l" + oldwhich + sR);
		eval("roll('n',"+oldwhich+",'Off','lN')")
		ol.visibility = invis;
	}
	l.visibility = vis;
	oldwhich = which;
	clearTimeout(layerTimer);
	return;
	}
	
//turn off layer and rollover if user is completely off nav 

	function stopOver()
	{
		//add by jami start 
		//加個flg判斷，若x>5的話就不再下跑，以免造成無窮迴圈
		//可是，若x>5就不執行的話，會產生什麼現象呢？
		var  tmpGoOrNot='go'
		//add by jami end
		//為什麼這裡要用5呢？←add by jami

		if (x<5) x++;
		else
		{
		ol = eval(lR + "l" + oldwhich + sR);
		ol.visibility = invis;
		eval("roll('n',"+oldwhich+",'Off','lN')")
		x=0;
		tmpGoOrNot='no'
		return 
		}

	if (tmpGoOrNot=='go')
		{
	   	 layerTimer = setTimeout("stopOver()",150)
		}
	}
	
//reset the timer
	function startOver()
	{
	x=0
	clearTimeout(layerTimer);
	}
	
//change subnav background color (ie5+ ns6+)
	function changebg(item, color)
{
	if (document.getElementById)
	{
	theone = eval("document.getElementById('"+item+"')")
	theone.style.background = color
	}	

}


//netscape resize bug fix
function NSresize() {
  if (document.FIX.NSfix.initWindowWidth != window.innerWidth || document.FIX.NSfix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function NSCheck() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.FIX == 'undefined'){
      document.FIX = new Object;
    }
    if (typeof document.FIX.FIX_scaleFont == 'undefined') {
      document.FIX.NSfix = new Object;
      document.FIX.NSfix.initWindowWidth = window.innerWidth;
      document.FIX.NSfix.initWindowHeight = window.innerHeight;
    }
    window.onresize = NSresize;
  }
}

NSCheck()


var goTimer = 0;
var goNum = 1;
var animLayerCount =3;
var pauseCount = 100;




function setUp()
	{
		for (i=1; i < animLayerCount; i++){
		layer = eval(lR + "z" + i + sR);
		if (isIE) layer.pixelLeft = -320;
		else layer.left = -320;
		layer.visibility = vis;
		}
	}
	
var timer;


function moveIt(whichLayer, toWhere, speed)
{
layer = eval(lR + whichLayer + sR);

if (isIE) theleft = parseInt(layer.pixelLeft)
else theleft = parseInt(layer.left)


// calculate the distance remaining
rDistance = toWhere - theleft;


// set the speed to a fraction of the remaining distance
speed = rDistance * .05;


// create a pocket buffer just a short distance before destination
toWhereBuffer = toWhere - 6;


// if object has not reached the buffer zone
if ( theleft <= 152) 
{
	if(isIE) layer.pixelLeft = parseInt(layer.pixelLeft) + speed
	else layer.left = parseInt(layer.left) + speed
}
else
{
	// if object has reached buffer zone, set object to destination
	return;
}
//loop
harold = "\"moveIt('" + whichLayer + "', 172, 2)\"";
eval ("timer= setTimeout(" + harold + ", 1)")

}

function textAnimate (){
	if (goNum >= animLayerCount){
	clearTimeout (myTimeOut);
	return;
} else {
	goName = "z" + goNum;
	moveIt(goName, 152, 2);
	pauseCount=pauseCount+800;
	
	
	//if (goName=="z3") pauseCount = 300
	goNum++;
}
	myTimeOut = setTimeout("textAnimate()", pauseCount);
	
}


function pickBrowser()
{/*--
if (isIE) moveLayers()
else {location.reload()}
--*/
}	

var width
/*--
function moveLayers()
{
if (isNS || isNS6) width= window.innerWidth
if (isIE) width= document.body.clientWidth

	for (q=1;q<6;q++)
	{
	l = eval(lR + "p" +q+ sR);
	//alert('ddd-'+lR)
	//alert('ddd-'+sR)
	if (q > 1) lOld = eval(lR + "p" + (q-1) + sR)
		if(width > 745)
		{
			if (q==1)
			{
				if (isIE) l.pixelLeft = width-267
				else if (isNS6)l.left = width-267
				else l.left = width-282
			}
			if (q>2)
			{
			if(isIE || isNS6) end = width - 5 
			else end = width-20
			start = 312
			middle = end-start
				if(isIE) l.pixelLeft = parseInt(lOld.pixelLeft) + middle/3
				else l.left = parseInt(lOld.left) + middle/3 
			}
		}
		else if (width <745)
		{
			if (q==1)
			{
			if(isIE) l.pixelLeft = 476
			else l.left = 476
			}
			if (q>2)
			{
			if(isIE) l.pixelLeft = parseInt(lOld.pixelLeft) + 142
			else l.left = parseInt(lOld.left) + 142
			}
		}
	}
}
	
--*/

//homepage image rollover

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

 

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

 

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

 

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

