// JavaScript Document
function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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 flevStartPersistentLayer() { // v3.4
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
	if (arguments.length < 8) {return;}	var sD = arguments[0]; if (sD == "") {return;}
	var	oD = eval("MM_findObj('" + sD + "')"); if (!oD) {return;} var iCSS = parseInt(arguments[1]);
	var sXL = arguments[2], sXC = arguments[3], sXR = arguments[4], sYT = arguments[5], sYC = arguments[6], sYB = arguments[7];
	var iS = (arguments.length > 8) ? parseInt(arguments[8]) : 0, iPx = (arguments.length > 9) ? parseInt(arguments[9]) : 0;
	if (iCSS != 0) { if (!document.layers) {oD = oD.style;} sXL = parseInt(oD.left), sYT = parseInt(oD.top);}
	var sF = "flevPersistentLayer('" + sD + "','" + sXL + "','" + sXC + "','" + sXR + "','" + sYT + "','" + sYC + "','" + sYB + "'," + iS + "," + iPx + ")";
	eval(sF);
}


function flevPersistentLayer() { // v3.4
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
	var sD = arguments[0], oD = eval("MM_findObj('" + sD + "')"), iWW, iWH, iSX, iSY, iT = 50, sS = "";
	if (!document.layers) {
		oD = oD.style;
	}
	if (oD.tmpTimeout != null) {
		clearTimeout(oD.tmpTimeout);
	}
	var sXL = arguments[1], sXC = arguments[2], sXR = arguments[3], sYT = arguments[4], sYC = arguments[5], sYB = arguments[6];
	var iS = (arguments.length > 7) ? parseInt(arguments[7]) : 0, iPx = (arguments.length > 8) ? parseInt(arguments[8]) : 0;
	if (window.innerWidth) {
		var oW = window;
		iWW = oW.innerWidth;
		iWH = oW.innerHeight;
		iSX = oW.pageXOffset;
		iSY = oW.pageYOffset;
	}else if (document.documentElement && document.documentElement.clientWidth){
		var oDE = document.documentElement; iWW = oDE.clientWidth; iWH = oDE.clientHeight; iSX = oDE.scrollLeft; iSY = oDE.scrollTop;
	}
	else if (document.body) {
		var oDB = document.body;
		iWW = oDB.clientWidth;
		iWH = oDB.clientHeight;
		iSX = oDB.scrollLeft;
		iSY = oDB.scrollTop;
	}
	else {
		return;
	}
	var iCX = iNX = flevGetDivProperty(sD, 'left'), iCY = iNY = flevGetDivProperty(sD, 'top');
	if (sXL != "") {
		iNX = iSX + parseInt(sXL);
	}
	else if (sXC != "") {
		iNX = Math.round(iSX + (iWW/2) - (flevGetDivProperty(sD, 'width')/2));
	}
	else if (sXR != "") {
		iNX = iSX + iWW - (flevGetDivProperty(sD, 'width') + parseInt(sXR));
	}
	if (sYT != "") {
		iNY = iSY + parseInt(sYT);
	}else if (sYC != "") {
		iNY = Math.round(iSY + (iWH/2) - (flevGetDivProperty(sD, 'height')/2));
	}
	else if (sYB != "") {
		iNY = iSY + (iWH - flevGetDivProperty(sD, 'height') - parseInt(sYB));
	}
	if ((iCX != iNX) || (iCY != iNY)) {
		if (iS > 0) {
			if (iPx > 0) {
				iT = iS;
				var iPxX = iPx, iPxY = iPx, iMX = Math.abs(iCX - iNX), iMY = Math.abs(iCY - iNY);
				// take care of diagonal movement
				if (iMX < iMY) {
					iPxY = (iMX != 0) ? ((iMY/iMX)*iPx) : iPx;
				}else{
					iPxX = (iMY != 0) ? ((iMX/iMY)*iPx) : iPx;
				}
				
				if (iPxX >= iMX) {
					iPxX = Math.min(Math.ceil(iPxX), iPx);
				}
				
				if (iPxY >= iMY) {
					iPxY = Math.min(Math.ceil(iPxY), iPx);
				}
				// temporary X/Y coordinates
				if ((iCX < iNX) && (iCX + iPxX < iNX)) {
					iNX = iCX + iPxX;
				}
				
				if ((iCX > iNX) && (iCX - iPxX > iNX)) {
					iNX = iCX - iPxX;
				}
				
				if ((iCY < iNY) && (iCY + iPxY < iNY)) {
					iNY = iCY + iPxY;
				}
				
				if ((iCY > iNY) && (iCY - iPxY > iNY)) {
					iNY = iCY - iPxY;
				}
			}else{
				var iMX = ((iNX - iCX) / iS), iMY = ((iNY - iCY) / iS);
				iMX = (iMX > 0) ? Math.ceil(iMX) : Math.floor(iMX); iNX = iCX + iMX; 
				iMY = (iMY > 0) ? Math.ceil(iMY) : Math.floor(iMY); iNY = iCY + iMY;
			}
			//oD.position = "absolute";
		}
		
		if ((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1) && (!window.opera)) {
			sS="px";
		}
		if (iMX != 0) {
			eval("oD.left = '" + iNX + sS + "'");
		}
		if (iMY != 0) {
			eval("oD.top = '" + iNY + sS + "'");
		}
	}
	
	var sF = "flevPersistentLayer('" + sD + "','" + sXL + "','" + sXC + "','" + sXR + "','" + sYT + "','" + sYC + "','" + sYB + "'," + iS + "," + iPx + ")";
	oD.tmpTimeout = setTimeout(sF,iT);
}

function flevGetDivProperty() { // v1.0
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl)
	this.opera = (window.opera); 
	this.ns4 = (document.layers); 
	this.ie = (document.all);
	this.ns6 = (document.getElementById && !document.all && !this.opera);
    var sV = "", sD = arguments[0], oD = MM_findObj(sD), sP = arguments[1];
	if (oD == null) {
		return 0;
	}
	var sF = (sD.indexOf("?") > 0) ? sD.substring(sD.indexOf("?")+1) : "";
	if ((sF != "") && (this.ie)) {
		sD = "parent.frames['" + sF + "']." + sD.substring(0,sD.indexOf("?"));
	}
	if ((sP == "left") || (sP == "top")) {
		if (!this.ns4) {
			oD = oD.style;
		}
		sV = eval("oD." + sP);
		if ((this.ie) && (sV == "")) { // IE (on PC) bug with nested layers
			if (sP == "top") {
				sV = eval(sD + ".offsetTop");
			}else{
				sV = eval(sD + ".offsetLeft");
			}
		}
	}else{
		if (this.opera) {
			oD = oD.style;
			if (sP == "height") { 
				sV = oD.pixelHeight;
			} 
			else if (sP == "width") { 
				sV = oD.pixelWidth;
			}
		}else if (this.ns4) {
			sV = eval("oD.clip." + sP);
		}
		else if (this.ns6) {
			sV = document.defaultView.getComputedStyle(oD, "").getPropertyValue(sP);
		}
	    else if (this.ie) {
			if (sP == "width") {
				sV = eval(sD + ".offsetWidth");
			}
			else if (sP == "height") {
				sV = eval(sD + ".offsetHeight");
			}
		}
	}
	sV = (sV == "") ? 0 : sV;
	if (isNaN(sV)) {
		if (sV.indexOf('px') > 0) {
			sV = sV.substring(0,sV.indexOf('px'));
		}
	}
	return parseInt(sV); 
}
function flevStopPersistentLayer() { // v3.4
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
	var sD = arguments[0], oD = MM_findObj(sD); if (!oD) {return;}
	if (!document.layers) {oD = oD.style;} if (oD.tmpTimeout != null) {clearTimeout(oD.tmpTimeout);}
}

// 去除頭尾空白
function Trim(stringToTrim){
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

// 判斷是否為  0~9
function isDigit(s) {
	var patrn=/^[0-9]{1,20}$/;
	if (!patrn.exec(s)) {
		return false;
	}
	return true;
}

// 判斷 Mail 格式是否正確
function isValidEmail(str) {
   	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


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 flvFTSS4(){//v1.02
this.style.filter="";}
function flvFTSS3(){//v1.02
var v1=arguments,v2=v1[0],v3=MM_findObj(v2);if (v3&&v3.TSS2!=null){clearTimeout(v3.TSS2);}}
function flvFTSS2(){//v1.02
var v1=arguments,v2=v1[0],v3=MM_findObj(v2),v4=v1[1],v5=v1[2],v6,v7,v8,v9,v10,v11,v12=document;if (v3&&v3.TSS8){flvFTSS3(v2);v9="flvFTSS2('"+v2+"',"+v4+","+v5+")";if (v4==1){if (!v3.TSS6.complete){v3.TSS2=setTimeout(v9,50);return;}v6=v3.TSS10+1;if (v6>v3.TSS8.length-1){if (v3.TSS11==0){return;}else {v6=0;}}else if (v6+1<v3.TSS8.length){v3.TSS6.src=v3.TSS8[v6+1][0];}}else {if (!v3.TSS3.complete){v3.TSS2=setTimeout(v9,50);return;}v6=v3.TSS10-1;if (v6<0){if (v3.TSS11==0){return;}else {v6=v3.TSS8.length-1;}}else if (v6-1>0){v3.TSS3.src=v3.TSS8[v6-1][0];}}v3.TSS10=v6;v10=v3.TSS8[v6][0];v11=v3.TSS8[v6][1];v7=(v3.filters&&!v12.TSS7&&v11<25);if (v7){if (v3.filters[0]&&v3.filters[0].status==2){v3.filters[0].Stop();}if (v11==0){v8="blendTrans(Duration="+v3.TSS9+")";}else {v8="revealTrans(Duration="+v3.TSS9+",Transition="+(v11-1)+")";}v3.style.filter=v8;v3.onfilterchange=flvFTSS4;v3.filters[0].Apply();}v3.src=v10;if (v7){v3.filters[0].Play();}if (v5==1){v3.TSS2=setTimeout(v9,v3.TSS4);}}}
function flvFTSS1(){//v1.02
var v1=arguments,v2=document,v3=v1[0],v4=MM_findObj(v3),v5,v6;if (v4){v2.TSS7=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);v4.TSS5=v4.src;v4.TSS9=v1[1]/1000;v4.TSS4=v1[2]+v1[1];v6=v1[3];v4.TSS11=v1[4];v4.TSS8=new Array();for (var v7=5;v7<v1.length;v7+=2){v4.TSS8[v4.TSS8.length]=new Array(v1[v7],v1[v7+1]);}v4.TSS10=0;v4.TSS6=new Image();v4.TSS6.src=v1[7];v4.TSS3=new Image();v4.TSS3.src=v1[v1.length-2];if (v6==1){v5="flvFTSS2('"+v3+"',1,"+v6+")";v4.TSS2=setTimeout(v5,v4.TSS4);}}}