﻿function funMenuMouseOver(objParent){
	var obj = objParent.getElementsByTagName("ul")
	if (obj.length > 0){
		obj[0].style.display='block';
	}
}
function funMenuMouseOut(objParent){
	var obj = objParent.getElementsByTagName("ul")
	for(i = 0; i < obj.length; i++) {
		obj[i].style.display='none';
	}
}

function funFlash(objID, objSource, objWidth, objHeight, objQuality, objWmode, objBgcolor) {

	var pageUrl = self.window.location.href;
	if(pageUrl.substring(0,5) == 'https') {
		swfUrl = "https";
	} else {
		swfUrl = "http";
	}
	if (objID == "") objID = 'ShockwaveFlash1';
	if (objWidth == "") objWidth = '0';
	if (objHeight == "") objHeight = '0';
	if (objQuality == "") objQuality = 'best';
	if (objWmode == "") {
		objWmode = 'transparent';
	} else {
		objWmode = '';
	}
	document.write('<object id="' + objID + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="' + objSource + '" codebase="' + swfUrl +'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="' + objWidth + '" height="' + objHeight + '">');
	document.write('<param name=menu value=false>');
	document.write('<param name=allowScriptAccess value=always>');
	document.write('<param name=wmode value="'+ objWmode +'">');
	document.write('<param name=movie VALUE="'+ objSource +'">');
	document.write('<param name=quality VALUE="'+ objQuality +'">');
	document.write('<param name=bgcolor VALUE="'+ objBgcolor +'">');
	document.write('<param name=allowFullScreen VALUE=true>');

	document.write('<embed allowScriptAccess="always" allowFullScreen="true" swLiveConnect="true" src="' + objSource + '" menu="false" quality="' + objQuality + '" wmode="' + objWmode + '" bgcolor="' + objBgcolor + '" width="' + objWidth + '" height="' + objHeight + '" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer">');
	document.write('</object>');
}

function funChangePhoto(strFile, obj){
	document.getElementById("imgPhoto").src = "/upload/publication/b/"+strFile;
	var objPhoto = document.getElementById("tdPhotoList").getElementsByTagName("img");
	var ns = (navigator.appName == "Netscape");
	for(i = 0; i < objPhoto.length; i++) {
		if (ns) {
			objPhoto[i].setAttribute("class","imgPhotoList");
		} else {
			objPhoto[i].className = "imgPhotoList";
		}
	}
	if (ns) {
		obj.setAttribute("class","imgPhotoListCurrent");
	} else {
		obj.className = "imgPhotoListCurrent";
	}
}

function funOpenWindow(theURL,WinName,width,height,scrollbars) {
	var DateTime = new Date();
	var windowName = 'Windows' + DateTime.getTime()
	var screenW = (screen.width - width) / 2
	var screenH = (screen.height - height) / 3
	features = 'width=' + width + ',height=' + height + ',left=' + screenW + ',top=' + screenH + ',scrollbars=' + scrollbars + ',resizable=yes',
	objWindow = window.open(theURL,WinName,features);
	objWindow.focus();
}

function funChangeBg(obj,strType){
	var ns = (navigator.appName == "Netscape");
	if (ns) {
		obj.setAttribute("class","trlist"+strType);
	} else {
		obj.className = "trlist"+strType;
	}

}

function funCheckData(){
	for(i = 1; i <= 20; i++) {
		var strID = "tdQ"+i;
		var obj = document.getElementById(strID).getElementsByTagName("input");
		if (obj[0].checked==false && obj[1].checked==false && obj[2].checked==false && obj[3].checked==false){
			alert("您還沒選擇題目 "+i+" 的答案喔，請全部作答案完畢再按確定按鈕。");
			obj[0].focus();
			return false;
		}
	}
	return true;
}

function funCheckSearch(){
	var obj =  document.getElementById("texSearch");
	if (obj.value==""){
		alert("請輸入搜尋關鍵字。");
		obj.focus();
		return false;
	}
	return true;
}




function funCheckNewsletter(){
	var obj =  document.getElementById("email2");
	if (obj.value==""){
		alert("請輸入訂閱或取消訂閱的電子郵件帳號。");
		obj.focus();
		return false;
	}
	return true;
}

function funShowAlert(strMsg){
    alert(strMsg);
}


function funSearch(strKeyword){
	location.href='/search.php?keyword='+strKeyword;
}
