﻿// SranM Guestbook Version 2.2
// Common JavaScript


// 帶確認的超鏈接
function go(URL,cfmText)
{
	var ret;
	ret = confirm(cfmText);
	if(ret!=false)window.location=URL;
}

// 打開自定義窗口
function openwin(URL, width, height)
	{
	var win = window.open(URL,"openscript",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=1,menubar=0,status=1');
	}

// 打開查看回復的窗口
function openreply()
	{
	document.viewreply.replycodes.value=document.replyform.replycode.value;
	var popupwin = window.open('viewreply.asp', 'viewreply_page', 'scrollbars=yes,width=700,height=450');
	document.viewreply.submit()
	}

// 檢查必填項
function Submitcheck()
	{
	if (document.lw_form.username.value.length==0){
	alert("請輸入您的姓名，此為必填項！");
	document.lw_form.username.focus();
	return false;
		}
	if (document.lw_form.usermail.value.length==0){
	alert("請輸入您的郵箱，此為必填項！");
	document.lw_form.usermail.focus();
	return false;
		}
	if (document.lw_form.usercontent.value.length==0){
	alert("請輸入留言內容，此為必填項！");
	document.lw_form.usercontent.focus();
	return false;
		}
	return true
	}

// 選中全部復選框
function CheckAll(form)
	{
	for (var i=0;i<form.elements.length;i++){
	var e = form.elements[i];
	if (e.name != 'chkall')
		e.checked = form.chkall.checked;
		}
	}

// 頁面跳轉
function MM_jumpMenu(targ,selObj,restore)
	{
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
	}

// 確認批量操作
function SetSubmitType(sub_type)
	{
	if (confirm("確定要執行批量操作嗎？")){
	SetSubmitType = sub_type;
		}
	}

// 選擇操作類型
function Submit_all(theForm)
	{
	var flag = false;
		if ( SetSubmitType == 'del'){
			flag = true;
			theForm.action = theForm.action + "del";
		}
		else if (SetSubmitType == 'check'){
			flag = true;
			theForm.action = theForm.action + "check";
		}
	return flag;
	}
