﻿
function funChangeImage(obj) {
	var imgUrl = obj.src.toLowerCase();
	if ( imgUrl.indexOf("over.") > 0 ) {
		obj.src = imgUrl.replace("over.","out.");
	} else {
		obj.src = imgUrl.replace("out.","over.");
	}
}

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 funShowFlash(strSwfID, strSwfFile, intWidth, intHeight, intQuality, strWmode, strBgcolor) {
	var pageUrl = self.window.location.href;
	if(pageUrl.substring(0,5) == 'https') {
		swfUrl = "https";
	} else {
		swfUrl = "http";
	}
	if (strSwfID == "")		{strSwfID = 'Swf'};
	if (intWidth == "")		{intWidth = '0'};
	if (intHeight == "")	{intHeight = '0'};
	if (intQuality == "")	{intQuality = 'best'};
	if (strWmode == "")		{strWmode = 'transparent'};
	document.write('<object id="' + strSwfID + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="' + strSwfFile + '" codebase="' + swfUrl +'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="' + intWidth + '" height="' + intHeight + '">');
	document.write('<param name=menu value=false>');
	document.write('<param name=allowScriptAccess value=always>');
	document.write('<param name=wmode value="'+ strWmode +'">');
	document.write('<param name=movie VALUE="'+ strSwfFile +'">');
	document.write('<param name=quality VALUE="'+ intQuality +'">');
	document.write('<param name=bgcolor VALUE="'+ strBgcolor +'">');
	document.write('<embed allowScriptAccess="always" swLiveConnect="true" src="' + strSwfFile + '" menu="false" quality="' + intQuality + '" wmode="' + strWmode + '" bgcolor="' + strBgcolor + '" width="' + intWidth + '" height="' + intHeight + '" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer">');
	document.write('</object>');
}

function funShowSubMenu(numID){
	var objDiv = document.getElementById("divSubMenu").getElementsByTagName("div");
	for (var i = 0; i < objDiv.length; i++) {
		objDiv[i].style.display = 'none';
	}
	objDiv[numID].style.display = '';
}

function funCheckTextareaLength(obj, limit, strSpanID){
	if (obj.value.length>limit){
		obj.value = obj.value.substring(0, limit);
	}
	if (strSpanID != ""){
		var objSpan = document.getElementById(strSpanID);
		objSpan.innerText = obj.value.length;
	}
}

function funCheckSearchData(){
	var obj = document.getElementById("texSearch");
	if (obj.value==""){
		alert("請輸入關鍵字。"); 
		obj.focus(); 
		return false;
	}
	if (obj.value.length < 2){
		alert("關鍵字至少需輸入 2 個字元。"); 
		obj.focus(); 
		return false;
	}
	return true;
}

function funConfirmReplyDelete(strID){ 
	if (confirm('確定刪除留言?')) {
		location.href="/code/reply/reply_delete.php?replyid="+strID;
	}
}
