<!--
// Nannette Thacker http://www.shiningstar.net

function confirmSubmit()
{
	var agree=confirm("你確定要繼續嗎? ");
	if (agree)
		return true ;
	else
		return false ;
}

function checkAddGuest(form) {
	var msg = "";

	if( isEmpty(form.company.value) || isEmpty(form.name.value) || isEmpty(form.age.value) ) {
		msg = "您有欄位尚留空白，請注意打星號 (*) 的地方。\n";
		alert(msg);
		return false;
	}
	if( checkPhone(form.mobile.value) != '' ) {
		msg = "您的手機號碼填寫不正確。\n";
		alert(msg);
		return false;
	}
	if( checkPhone(form.tel.value) != '' ) {
		msg = "您的聯絡電話填寫不正確。\n";
		alert(msg);
		return false;
	}
	if( checkEmail(form.email.value) != '' ) {
		msg = "您填寫的 E-Mail 信箱有問題。\n";
		alert(msg);
		return false;
	}

	return true;
}

// From http://developer.apple.com/internet/webcontent/validation.html
// email

function checkEmail (strng) {
	var error="";
	if (strng.length == 0 ) {
		error = "您並未輸入 E-mail 信箱。\n";
	}

	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng))) { 
		error = "您輸入的 E-mail 信箱不正確。\n";
	}
	else {
//test email for illegal characters
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars)) {
			error = "您輸入的 E-mail 信箱有不正常的字元。\n";
		}
	}
	return error;
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
	var error = "";
	if (strng.length == 0 ) {
		error = "您並未輸入電話號碼。\n";
	}
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
		error = "您輸入的電話號碼有問題。";
	}
	return error;
}

// non-empty textbox

function isEmpty(strng) {
	if (strng.length == 0) {
		return true;
	}
	return false;
}

function switchdisplay(strng) {
	a = document.getElementById(strng).style.display;
	document.getElementById(strng).style.display=(a=='none')?'block':'none';
}

// -->