﻿var searchflag = 0;

function searchfocus() {
   if (searchflag == 0) {
      searchflag = 1;
      document.Frmsitesearch.q.value = "";
   }
}

function searchblur() {
   if (document.Frmsitesearch.q.value == "") {
      searchflag = 0;
      document.Frmsitesearch.q.value = "請輸入關鍵字";
   }
}

var menu = new Menu("esdlife_news_menu", "esdlife_news_menu");
menu.addItem("生活易盛事", "http://www.esdlife.com/esd_events/chi/default.asp", "menu_item_over", "menu_item_out");
menu.addItem("生活易新聞中心", "http://www.esdlife.com/about_us/chi/press/default.asp", "menu_item_over", "menu_item_out");
menu.addItem("獎賞結果告示板", "http://www.esdlife.com/esd_announce/chi/default.asp", "menu_item_over", "menu_item_out");

/* This function returns the upperleft x,y coordinates of the specified image */
function imgXY(imgID) {
	var XY = new Object();
	var imgObj = document.images[imgID];
	if (document.layers) {
		XY.x = eval(imgObj).x;
		XY.y = eval(imgObj).y;
	} else {
		var x,y, tempEl;
		x = eval(imgObj).offsetLeft;
		y = eval(imgObj).offsetTop;
		tempEl = eval(imgObj).offsetParent;
		while (tempEl != null) {
			x += tempEl.offsetLeft;
			y += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		XY.x = x;
		XY.y = y;
	}
	return XY;
}

function showESDNewsMenu() {
	MM_swapImage('btn09','','http://www.esdlife.com/common_img/chi/btn09_on.gif',1);
	var imgPos = imgXY("btn09");
	menu.getMenu().style.left = imgPos.x;
	menu.getMenu().style.top = imgPos.y + 25;
	menu.getMenu().style.display = "";
}

function hideESDNewsMenu() {
	setTimeout("realHideESDNewsMenu()", 200);
}

function realHideESDNewsMenu() {
	if (menu.getMouseOverStatus() == false) {
		MM_swapImgRestore();
		menu.getMenu().style.display = "none";
	}
}

function mainBodyOverBtn(arrayBtn, strOverBtnId) {
	var objImg, objDiv;
	for (var i=0; i<arrayBtn.length; i++) {
		objImg = document.getElementById(arrayBtn[i][0]);
		objDiv = document.getElementById(arrayBtn[i][3]);
		if (strOverBtnId == arrayBtn[i][0]) {
			objImg.src = arrayBtn[i][2];
			objDiv.style.display = "";
			arrayBtn[i][4] = 1;
		} else {
			objImg.src = arrayBtn[i][1];
			objDiv.style.display = "none";
			arrayBtn[i][4] = 0;
		}
	}
}

function displayAdvDisclaimer(strStatus) {
	var imgPos = imgXY("adv_disclaimer_img");
	var objDiv = document.getElementById("adv_disclaimer");
//	objDiv.style.left = imgPos.x;
//	objDiv.style.top = imgPos.y + 20;
	objDiv.style.display = strStatus;
}

var boolPauseESDNewsRotate = false;

function mainBodyAutoRotate(strArrayBtnName, intSpeed) {
	eval("var arrayTemp = " + strArrayBtnName);
	var intCurrentIndex;
	for (var i=0; i<arrayTemp.length; i++) {
		if (arrayTemp[i][4] == 1) {
			intCurrentIndex = i;
			break;
		}
	}
	intCurrentIndex = (intCurrentIndex + 1) % arrayTemp.length;
	if (strArrayBtnName == "arrayESDNewsBtn") {
		if (boolPauseESDNewsRotate == false) {
			mainBodyOverBtn(arrayTemp, arrayTemp[intCurrentIndex][0]);
		}
	} else {
		mainBodyOverBtn(arrayTemp, arrayTemp[intCurrentIndex][0]);
	}
	setTimeout("mainBodyAutoRotate('" + strArrayBtnName + "', " + intSpeed + ")", intSpeed);
}

function esd_swapDiv() {
	var obj, args=esd_swapDiv.arguments;
	if (args.length > 1) {
		for (i=0; i<args.length; i++) {
			obj = MM_findObj(args[i]);
			if (obj != null) {
				if (i == 0) {
					obj.style.display = "";
				} else {
					obj.style.display = "none";
				}
			}
		}
	}
}