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];}
}
function display(nod,num){
	var tmp = nod.parentNode.parentNode.parentNode.childNodes[num];
	if (tmp.style.display=='none'){
		tmp.style.display='block'
	}else{
		tmp.style.display='none'
	}
}
function play(num,aid){
	var winPaly = window.open('../base/play.asp?NO='+num+'&AID='+aid,'play','top=30,left=140,width=436,height=588,scrollbars=yes,resizable=no,menubar=yes')
	winPaly.window.focus();
}

var timerID = null
var timerRunning = false
var charNo = 0
var charMax = 0
var lineNo = 0
var lineMax = 3
var lineArr = new Array(lineMax)
var urlArr = new Array(lineMax)
lineArr[1] = "公司更多資訊"
urlArr[1] = "index.asp?module=intro"
lineArr[2] = "公司更多資訊"
urlArr[2] = "index.asp?module=intro"
lineArr[3] = "公司更多資訊"
urlArr[3] = "index.asp?module=intro"
lineArr[4] = "公司更多資訊"
urlArr[4] = "index.asp?module=intro"

var lineText = lineArr[1];
function StartShow() {
	StopShow()
	ShowLine()
	timerRunning = true
}
function StopShow() {
	if (timerRunning) {
		clearTimeout(timerID)
		timerRunning = false
	}
}
function ShowLine() {
	if (charNo == 0) { // Next line
		if (lineNo < lineMax) 	{
			lineNo++
		}
		else {
			lineNo = 1
		}
		lineText = lineArr[lineNo]
		charMax = lineText.length
	}
	if (charNo <= charMax) { // Next char
		document.formDisplay.buttonFace.value = lineText.substring(0, charNo)
		charNo++
		timerID = setTimeout("ShowLine()", 100)
	}
	else {
		charNo = 0
		timerID = setTimeout("ShowLine()", 3000)
	}
}
function GotoUrl(url)
{
	location.href = url
}
//---------------------------------------------
//開始計時的時間
var mmStart;
//等待隱藏時間的長短
var timeout=500;
//等待隱藏的物件
var mmInTimerobj;
//目前在計時的程序
var mmHideMenuTimer=null;
//不能隱藏Div名稱
var NotHiddenDivs = new Array(); 
//---------------------------------------------
//取得絕對位置程式
function getPos(el,sProp)  
{
	var iPos = 0;
	while (el!=null)  
　　 {
		iPos+=el["offset" + sProp] || 0;
		el = el.offsetParent;
	 } 
    return iPos;
}  

//---------------------------------------------
//清除計時的程序
function MM_clearTimeout() {
	if (mmHideMenuTimer){
		clearTimeout(mmHideMenuTimer);	
		mmHideMenuTimer = null;
	}
}

//---------------------------------------------
//開始一個計時程序每500毫秒一次
function MM_startTimeout() {
	NotHiddenDivs=null;
	mmStart = new Date();
	mmHideMenuTimer = setTimeout("mmDoHide()", 500);
}

//---------------------------------------------
//判斷隱藏的程式
function mmDoHide() {
	var elapsed = new Date() - mmStart;
	if (elapsed < timeout) {
		mmHideMenuTimer = setTimeout("mmDoHide()", timeout+100-elapsed);
		return;
	}
	ToHiddenAllDiv();
	mmHideMenuTimer=null;
}
//---------------------------------------------
//發現物件
function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

//---------------------------------------------
//設定不能隱藏DIV 及顯示DIV
function ShowMenu(el,NotHiddenDivStr,actMenu,isRoot){
	var ActiveMenu;
	MM_clearTimeout();	
	if (!NotHiddenDivs){
		NotHiddenDivs = NotHiddenDivStr.split(",");	
		ToHiddenAllDiv();
	}
	if (FIND(actMenu)){
		ActiveMenu=FIND(actMenu);
		if (ActiveMenu) {
			if (isRoot=='root'){
				ActiveMenu.style.pixelLeft=getPos(el.offsetParent,"Left"); 
				ActiveMenu.style.pixelTop=getPos(el.offsetParent,"Top") + el.offsetParent.offsetHeight-5;
			}else{
				ActiveMenu.style.pixelLeft=getPos(el.offsetParent,"Left")+el.offsetWidth-5;
				ActiveMenu.style.pixelTop=getPos(el.offsetParent,"Top")+5;
			}
			ActiveMenu.style.position='absolute'; 
			ActiveMenu.style.display='block'; 
		}
	}
}
//---------------------------------------------
//隱藏所有可隱藏的DIV
function ToHiddenAllDiv(){
	var Divstr,hiddenFlg;
	for (var i=0; i<50; i++) {
		Divstr="menuDiv_"+i;
		hiddenFlg=true;
		if (NotHiddenDivs){
			for (var j=0;j<NotHiddenDivs.length;j++){	
				if (NotHiddenDivs[j]==Divstr){
					hiddenFlg=false;
				}			
			}
		}
		if (hiddenFlg){
			if (FIND("menuDiv_"+i)){
				var toHiddenDiv = FIND("menuDiv_"+i);
				toHiddenDiv.style.display='none';
			}
		}
	}
}
//---------------------------------------------
//不做任何事件時
function NoEven(){
	return;
}
var nowNode;
function loadXMLDoc(node,url)
{
// code for IE
  nowNode = node;
  if (window.ActiveXObject)
  {
  //xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){}
		}
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=xmlhttpChange
    xmlhttp.open("GET",url,true)
	//xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.send(null)
    }
  }
// code for Mozilla, etc.
  else if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=xmlhttpChange()
  xmlhttp.open("GET",url,true)
  xmlhttp.overrideMimeType('text/xml');
  xmlhttp.send(null)
  }
}
function xmlhttpChange()
{
// if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4)
  {
  // if "OK"
    if (xmlhttp.status==200)
    {
		var x = xmlhttp.responseText;
		if (x.indexOf("線上：")>0)
			nowNode.innerHTML = x.substring(x.indexOf("線上：")+3,x.indexOf("&nbsp;"));
		if (x.indexOf("累計：")>0)
			nowNode.nextSibling.innerHTML = x.substring(x.indexOf("累計：")+3,x.length);
    }
    else
    {
    //alert("Problem retrieving XML data")
    }
  }
}
var gPic = new Image();
var bFlag = false ;
function showGMap( src )
{
	MemPic.innerHTML = "";
	gPic.src = src ;
	gPic.height = 200;
	gPic.widht = 200;
	MemPic.appendChild(gPic );
	MemPic.style.height = "200px";
	MemPic.style.width = "200px";
	MemPic.style.marginLeft = "-210px";	
}
function down()
{
	if( gPic.width > 0 )
	{
		gPic.width = gPic.width - 20;
		gPic.height = gPic.height - 20 ;
		MemPic.style.width = (gPic.width) + "px";
		MemPic.style.height = (gPic.height) + "px";
		MemPic.style.marginLeft = (-1*(gPic.width)-10) + "px";
		setTimeout("down()",50);
	}
}
//移上小圖秀大圖
var tmpTid = false,pic = new Image();
function showpic(picpath){
	if(tmpTid) clearTimeout(tmpTid)
	MemPic.style.height="1px"
	MemPic.style.width="1px"
	pic.src =  picpath + "?tmp=" + Date.parse(new Date().toString());
	MemPic.innerHTML="";
	var XMLNode = document.createElement("img");
	//XMLNode.onclick = "'javascript:growdown(5)'"
	XMLNode.src=pic.src;
	MemPic.appendChild(XMLNode);
	tmpTid = setTimeout("growup(5)",200);
}
function growup(t){
	if (eval(pic.height))	{
		MemPic.style.display=''
		var tmpH = eval(MemPic.style.height.substr(0,MemPic.style.height.length-2))
		var tmpW = eval(MemPic.style.width.substr(0,MemPic.style.width.length-2))
		MemPic.style.height = pic.height + "px";
		if (pic.width>tmpW){
				MemPic.style.width = (tmpW + (2*(pic.height/100)*(pic.width/pic.height))) + "px";
				MemPic.style.marginLeft = (-1*tmpW-10)+'px';
				t = 2;
		}else{
			t = 0;
			if(tmpTid) clearTimeout(tmpTid)
			//tmpTid = setTimeout("growdown(" + (5) + ")",3000)
		}
		timeout = 2;
	}else{
		timeout = 500;
	}
	if (t>0) {
		if(tmpTid) clearTimeout(tmpTid)
		tmpTid = setTimeout("growup(" + (t-1) + ")",timeout)
	}
}
function growdown(t){
	if (pic.height)	{
		var tmpH = eval(MemPic.style.height.substr(0,MemPic.style.height.length-2))
		var tmpW = eval(MemPic.style.width.substr(0,MemPic.style.width.length-2))
		if ((tmpW - ( 2 *(pic.height/100) * (pic.width/pic.height))>0)){
				//if((tmpH -2*(pic.height/100))>0) MemPic.style.height = (tmpH -2*(pic.height/100)) + "px";
				if(tmpW - ( 2 *(pic.height/100) * (pic.width/pic.height))>0) MemPic.style.width = tmpW - ( 2 *(pic.height/100) * (pic.width/pic.height)) + "px";
				MemPic.style.marginLeft = (-1*tmpW+10)+'px';
				t = 2;
		}else{
			MemPic.style.height = "0px"
			MemPic.style.width = "0px"
			t = 0;
			MemPic.style.display='none'
		}
		timeout = 2;
	}else{
		timeout = 500;
	}
	if (t>0) {
		if(tmpTid) clearTimeout(tmpTid);
		tmpTid = setTimeout("growdown(" + (t-1) + ")",timeout)
	}
}